package com.hmdp.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hmdp.dto.Result;
import com.hmdp.entity.Follow;
import com.hmdp.service.IFollowService;
import com.hmdp.utils.UserHolder;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService iFollowService;

    /**
     * 查询是否关注当前博主
     *
     * @author Yhans
     * @date 2024/2/25 10:29
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long id) {
        return iFollowService.isFollow(id);
    }

    /**
     * 关注和取关博主
     *
     * @author Yhans
     * @date 2024/2/25 19:11
     */
    @PutMapping("/{id}/{followed}")
    public Result follow(@PathVariable("id") Long id, @PathVariable("followed") Boolean followed) {

        return iFollowService.follow(id, followed);
    }

    /**
     * 共同关注
     *
     * @author Yhans
     * @date 2024/2/25 19:11
     */
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Long id) {
        return iFollowService.followCommons(id);
    }

    /**
     * 查询用户粉丝列表
     * @author Yhans
     * @date 2024/2/25 16:03
     */
    @GetMapping("/fanList")
    public Result queryFanList() {
        return iFollowService.queryFanList();
    }
}
